<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <style>
        * {
            margin: 0;
            padding: 0;
            list-style: none;
        }

        ul {
            width: 509px;
            height: 56px;
            position: absolute;
            left: 20%;
            top: 40px;

        }

        .tongyi {
            height: 50px;
            width: 250px;
            background-color: red;
            border: 3px solid black;
        }

        .fandui {
            width: 250px;
            height: 50px;
            background-color: blue;
            float: right;
            border: 3px solid black;
        }

        .btn {
            position: absolute;
            left: 20%;
            top: 130px;

        }

        .btn1 {
            width: 100px;
            height: 50px;
            background-color: rgb(233, 25, 25);
            color: white;
            font-size: 20px;
            font-weight: 600;
            cursor: pointer;

        }

        .btn2 {
            cursor: pointer;
            width: 100px;
            height: 50px;
            background-color: rgb(25, 53, 233);
            color: white;
            font-size: 20px;
            font-weight: 600;
        }
    </style>

</head>

<body>


    <ul>
        <li class="fandui"></li>
        <li class="tongyi"></li>
    </ul>
    <div class="btn">
        <button class="btn1">同意</button> <span class="tnum">0</span><span>人</span><br>
        <button class="btn2">反对</button> <span class="fnum">0</span><span>人</span>
    </div>

</body>

</html>

<script src="./jquery-3.5.1.js"></script>
<script>
    $('.btn button').click(function () {
        // 修改点击人数
        let tnum = $(this).next().text();
        let tnum1 = tnum - 0 + 1
        $(this).next().text(tnum1)

        // 获取人数
        let num1 = $('.btn1').next().text()-0
        let num2 = $('.btn2').next().text()-0
        

        let p = num1 / (num1 + num2)

        // 计算双方的宽度
        let wid1 = 500 * p;
        let wid2 = 500 - wid1

        // 宽度实现在进度条上
        $('.tongyi').css('width', wid1)
        $('.fandui').css({"width": wid2,"border": "3px solid black"})


    })
</script>